<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="x-ua-compatible" content="ie=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=yes">
    <link rel="icon" type="image/png" href="../assets/favicon.ico">
    <!-- Google Tag Manager -->
    <script>(function (w, d, s, l, i) {
            w[l] = w[l] || []; w[l].push({
                'gtm.start':
                    new Date().getTime(), event: 'gtm.js'
            }); var f = d.getElementsByTagName(s)[0],
                j = d.createElement(s), dl = l != 'dataLayer' ? '&l=' + l : ''; j.async = true; j.src =
                    'https://www.googletagmanager.com/gtm.js?id=' + i + dl; f.parentNode.insertBefore(j, f);
        })(window, document, 'script', 'dataLayer', 'GTM-WQKS4BKW');</script>
    <!-- End Google Tag Manager -->
    <meta name="msapplication-TileColor" content="#808080">
    <meta name="msapplication-config" content="/wp-content/uploads/ico/browserconfig.xml">
    <meta name="theme-color" content="#808080">
    <!-- adsense -->
    <meta name='robots' content='max-image-preview:large' />
    <meta property='og:type' content='webpage'>
    <meta property='og:locale' content='en_US'>
    <meta property='og:site_name' content='onlinexzone.com'>
    <meta property='og:image:width' content='868'>
    <meta property='og:image:height' content='1300'>

    <link rel="stylesheet" href="./../category/public/public.css">

    <meta name="msapplication-TileImage" content="https://onlinexzone.com/assets/logo.png" />
    <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-6907038225839490"
        crossorigin="anonymous"></script>

</head>

<body class="bi-pagetype-single archive category category-health category-7 unified-pagetype-single unified-lang-en_US">
    <a class="skip-main" href="#main">Skip to main content</a>
    <div class="popout">
        <a class="popout__logo" href="https://onlinexzone.com/" aria-label="Go to onlinexZone Homepage">
            <img alt="onlinexZone logo" src="https://onlinexzone.com/assets/logo.png" class="popout__logo-image" width="160"
                height="30.06" />
        </a>

        <button class="popout__close" type="button" aria-label="Close Menu">

        </button>


        <nav class="popout-nav" aria-label="Pop Out Site Menu">
            <ul id="menu-popout-menu-english" class="popout-nav__list">
                <li id="menu-item-11654"
                    class="menu-item menu-item-type-taxonomy menu-item-object-category popout-nav__item menu-item-11654">
                    <a class="popout-nav__link" target="_parent"
                        href="https://onlinexzone.com/category/health/">Health</a>
                </li>
                <li id="menu-item-11659"
                    class="menu-item menu-item-type-taxonomy menu-item-object-category popout-nav__item menu-item-11659">
                    <a class="popout-nav__link" target="_parent"
                        href="https://onlinexzone.com/category/travel/">Travel</a>
                </li>
                <li id="menu-item-11657"
                    class="menu-item menu-item-type-taxonomy menu-item-object-category popout-nav__item menu-item-11657">
                    <a class="popout-nav__link" target="_parent"
                        href="https://onlinexzone.com/category/auto/">Auto</a>
                </li>
                <li id="menu-item-11655"
                    class="menu-item menu-item-type-taxonomy menu-item-object-category popout-nav__item menu-item-11655">
                    <a class="popout-nav__link" target="_parent"
                        href="https://onlinexzone.com/category/finance/">Finance</a>
                </li>
                <li id="menu-item-11656"
                    class="menu-item menu-item-type-taxonomy menu-item-object-category popout-nav__item menu-item-11656">
                    <a class="popout-nav__link" target="_parent"
                        href="https://onlinexzone.com/category/tech/">Tech</a>
                </li>
            </ul>
            <nav class="popout-secondary-nav" aria-label="Pop Out Privacy Menu" style="padding: 0;">
                <ul id="menu-popout-privacy-menu-english" class="popout-secondary-nav__list cmp__menu">
                    <li id="menu-item-11660"
                        class="menu-item menu-item-type-custom menu-item-object-custom popout-secondary-nav__item menu-item-11660">
                        <a class="popout-secondary-nav__link" target="_blank"
                            href="https://docs.google.com/document/d/17ydjwONuPcDChPCnV-DVzH6hqOB58B8TwUffEQvUYd4/pub">Privacy
                            Policy</a>
                    </li>

                </ul>
            </nav>
        </nav>

    </div>
    <div class="overlay"></div>
    <header class="header">
        <!-- logo -->

        <div class="logoBox">
            <a class="logo" href="https://onlinexzone.com" target="_parent" aria-label="Go to onlinexzone.com Homepage">
                <img alt="onlinexzone.com logo" src="https://onlinexzone.com/assets/logo.png" class="logo__image" />
            </a>
            <button class="hamburger" type="button" aria-label="Show Menu"><span
                    class="hamburger__span"></span></button>
        </div>

        <!-- mobile menu toggle -->



        <!-- primary menu -->
        <nav class="nav" aria-label="Site Menu">
            <ul id="menu-primary-menu-english" class="nav__list">
                <li id="menu-item-125"
                    class="menu-item menu-item-type-taxonomy menu-item-object-category nav__item menu-item-125"><a
                        class="nav__link" target="_parent"
                        href="https://onlinexzone.com/category/health/">Health</a></li>
                <li id="menu-item-128"
                    class="menu-item menu-item-type-taxonomy menu-item-object-category nav__item menu-item-128"><a
                        class="nav__link" target="_parent"
                        href="https://onlinexzone.com/category/travel/">Travel</a></li>
                <li id="menu-item-123"
                    class="menu-item menu-item-type-taxonomy menu-item-object-category nav__item menu-item-123"><a
                        class="nav__link" target="_parent"
                        href="https://onlinexzone.com/category/auto/">Auto</a></li>
                <li id="menu-item-124"
                    class="menu-item menu-item-type-taxonomy menu-item-object-category nav__item menu-item-124"><a
                        class="nav__link" target="_parent"
                        href="https://onlinexzone.com/category/finance/">Finance</a>
                </li>
                <li id="menu-item-127"
                    class="menu-item menu-item-type-taxonomy menu-item-object-category nav__item menu-item-127"><a
                        class="nav__link" target="_parent"
                        href="https://onlinexzone.com/category/tech/">Tech</a></li>
            </ul>
        </nav>
    </header>

    <main class="main main--category" id="main">
        <section class="hero hero--category">
            <h1 class="hero__heading">Auto</h1>

        </section>

        <section class="section section--variation-5">
            <h2 class="section__heading section__heading--variation-5">
                Auto Latest News </h2>
            <div class="post-module post-module--variation-5">

            </div>

            <section class="section">
                <nav class="pagination" aria-label="Page navigation"><a class='button button--pagination-next'
                        href="">See More</a></nav>
            </section>
        </section>
    </main>

    <!-- 底部版权 -->
    <!-- <iframe src="./../components/copyRight.html" frameborder="0" width="100%" height="0px"></iframe> -->
</body>
<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-WQKS4BKW" height="0" width="0"
        style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->

<script type="module">
    import {getAllUrlParams, addHeadElment, newsTypeObj} from '../utils/common.js'
    window.onload = function () {

        // 设置标题
        let pageTitleLow = getAllUrlParams().type || 'auto'
        let pageTitleUp = pageTitleLow.slice(0, 1).toUpperCase() + pageTitleLow.slice(1)
        let pageNo = Number(getAllUrlParams().page) || 1


        // see more
        const seeMore = document.querySelector('.button--pagination-next')
        // 俩标题
        const section__heading = document.querySelector('.section__heading')
        const hero__heading = document.querySelector('.hero__heading')
        hero__heading.innerText = pageTitleUp
        section__heading.innerText = pageTitleUp + ' Latest New'

        seeMore.addEventListener('click', function (e) {
            e.preventDefault()
            window.location.href = `https://onlinexzone.com/seeMore/index.html?type=${pageTitleLow}&page=${pageNo + 1}`
        })

        // 设置文章
        const newsObj = newsTypeObj
        let newsList = []

        if (newsObj[pageTitleLow]) {
            newsList = newsObj[pageTitleLow].filter(item => {
                return item.id > (pageNo * 5 + 2) && item.id <= ((pageNo + 1) * 5 + 2)
            })

            if (newsObj[pageTitleLow].length <= (pageNo + 1) * 5 + 3) {
                seeMore.style.display = 'none'
            }
        } else {
            for (let i in newsObj) {
                for (let j in newsObj[i]) {
                    if (newsObj[i][j].classfy === pageTitleLow) {
                        let obj = {...newsObj[i][j]}
                        obj.fatherClassfy = i
                        newsList.push(obj)
                    }
                }
            }

            if (newsList.length < pageNo * 5 + 1) {
                seeMore.style.display = 'none'
            }
            newsList = newsList.splice((Number(getAllUrlParams().page) - 1) * 5, 5)

            // 以后只有id大于7以后的才能出现在see more里，现在暂时可以出现在这里
            // newsList = newsList.filter(item =>{
            //     return item.id > 7
            // })
        }
        console.log(newsList);

        const seoArr = [
            {
                name: 'title',
                property: {
                },
                text: `${pageTitleUp} - onlinexzone.com`
            },
            {
                name: 'meta',
                property: {property: 'og:image', content: newsList[0] ? newsList[0].imgUrl : 'onlinexzone.com'}
            },
            {
                name: 'meta',
                property: {property: 'og:title', content: `Category ${pageTitleUp}`}
            },
            {
                name: 'meta',
                property: {property: 'og:url', content: `https://onlinexzone.com/category/${pageTitleLow}/index.html`}
            },
            {
                name: 'link',
                property: {rel: 'canonical', href: `https://onlinexzone.com/category/${pageTitleLow}/index.html`}
            },
        ]
        // seo优化
        for (let i in seoArr) {
            addHeadElment(seoArr[i].name, seoArr[i].property, seoArr[i].text)
        }
        if (!newsList.length) return
        const newsBox = document.querySelector('.post-module--variation-5')
        for (let i in newsList) {
            const article = document.createElement('article')
            article.className = 'post-module__item'
            article.innerHTML = `
                   <a class="post-module__thumb-link"
                       href="${newsList[i].articleUrl}">
                       <span class="screen-reader-text">${newsList[i].newsTitle}</span>
                       <img loading='lazy'
                           src='${newsList[i].imgUrl}?image_process=quality,q_20'
                           sizes='(max-width:576px) 30vw, (max-width:992px) 50vw, (max-width:1400px) 100vw, 900w'
                           width="600" height="315"
                           data-src="${newsList[i].imgUrl}?image_process=quality,q_20"
                           class="cdn-ih post-module__thumb wp-post-image" alt="" decoding="async" fetchpriority="high"
                           srcset="${newsList[i].imgUrl}?image_process=quality,q_20"
                           sizes="(max-width: 600px) 100vw, 600px" />
                           <noscript><img width="600" height="315"
                               src="${newsList[i].imgUrl}?image_process=quality,q_20"
                               class="post-module__thumb wp-post-image" alt="" decoding="async" fetchpriority="high"
                               sizes="(max-width: 600px) 100vw, 600px" /></noscript> </a>


                   <a class="post-module__category-link" href="https://onlinexzone.com/category/${newsList[i].fatherClassfy ? newsList[i].fatherClassfy : pageTitleLow}/index.html'"
                       aria-label="More from Health">
                       <span class="post-module__category">${newsList[i].fatherClassfy ? newsList[i].fatherClassfy.slice(0, 1).toUpperCase() + newsList[i].fatherClassfy.slice(1) : pageTitleUp}</span>
                   </a>
                   <h3 class="post-module__heading">
                       <a class="post-module__heading-link"
                           href="${newsList[i].articleUrl}">${newsList[i].newsTitle} </a>
                   </h3>
                   <div class="post-module__description">
                       <p>${newsList[i].seoText ? newsList[i].seoText : newsList[i].newsTitle}</p>
                   </div>
                   <a class="post-module__button"
                       href="${newsList[i].articleUrl}">Read
                       More<span class="screen-reader-text"> ${newsList[i].seoText ? newsList[i].seoText : newsList[i].newsTitle}</span></a>
                   <p class="post-module__read-time">${Math.floor(Math.random() * (10 + 1) + 1)} minute read</p>
            `
            newsBox.appendChild(article)
        }
    }

</script>

<script>
    // 隐藏侧边导航栏
    const popout = document.querySelector('.popout')
    // 关闭按钮
    const popout__close = document.querySelector('.popout__close')
    // 遮罩
    const overlay = document.querySelector('.overlay')
    const hamburger = document.querySelector('.hamburger')
    hamburger.addEventListener('click', function () {
        blockAside();
    })
    popout__close.addEventListener('click', function () {
        popout.classList.remove("popout--visible");
        overlay.classList.remove("overlay--visible")
        popout__close.classList.remove("popout__close--active")

    })
    function blockAside() {
        popout.classList.add("popout--transition", "popout--visible");
        overlay.classList.add("overlay--visible")
        popout__close.classList.add("popout__close--active")
        console.log('我是父页面的方法')
    }

    // 监听主题变化做的事
    let mqList = window.matchMedia('(prefers-color-scheme: dark)');
    const logoImg = document.querySelector('.logo__image')
    function switchColor() {
        if (mqList.matches) {
            // logoImg.src = logoImg.src.split('.png')[0] + '_dark' + '.png'
        }
    }
    switchColor()

    mqList.addEventListener('change', (event) => {
        // is dark mode
        if (event.matches) {
            switchColor()
        } else {
            // not dark mode
        }
    });
</script>

</html>